package pay.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.xuegengwang.xuegengwang.R;

import java.util.ArrayList;

import pay.bean.EncashHistoryBean;

/**
 * Created by Administrator on 2017/4/27.
 */

public class EncashAdapter extends BaseAdapter {
    private ArrayList<EncashHistoryBean.RecordBean> arrayList;
    private Context context;

    public EncashAdapter(Context context, ArrayList<EncashHistoryBean.RecordBean> arrayList) {
        this.arrayList = arrayList;
        this.context = context;
    }

    @Override
    public int getCount() {
        return arrayList.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Holder holder;
        if (convertView == null) {
            holder = new Holder();
            convertView = LayoutInflater.from(context).inflate(R.layout.encash_history_item, null);
            holder.encash_history_item_date = (TextView) convertView.findViewById(R.id.encash_history_item_date);
            holder.encash_history_item_weekday = (TextView) convertView.findViewById(R.id.encash_history_item_weekday);
            holder.encash_history_item_moeny = (TextView) convertView.findViewById(R.id.encash_history_item_money);
            convertView.setTag(holder);
        } else {
            holder = (Holder) convertView.getTag();
        }
        holder.encash_history_item_date.setText(arrayList.get(position).getCreate_time());
        holder.encash_history_item_moeny.setText("¥"+arrayList.get(position).getMoney());
        holder.encash_history_item_weekday.setText(arrayList.get(position).getWeek());
        return convertView;
    }

    class Holder {
        TextView encash_history_item_weekday;
        TextView encash_history_item_date;
        TextView encash_history_item_moeny;
    }
}
